<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/11/10
 * Time: 15:14
 */

namespace app\index\validate;


use think\Validate;

class Banner extends Validate
{
    protected $rule = [
        'title'  => 'require',
        'title_color'  => 'require',
        'banner_picture'  => 'require',
        'main_picture'  => 'require',
        'background_color'  => 'require',
        'product_ids'  => 'require|array',
        'activity_img' =>'require|imageCollection:',//图像集合
    ];
    protected $message=[
            'title.require'=>'请输入活动标题',
            'title_color.require'=>'请输入标题颜色',
            'banner_picture.require'=>'请输入活动图片',
            'main_picture.require'=>'请输入活动详情图片',
            'background_color.require'=>'请输入活动详情图片',
            'product_ids.require'=>'请选择参与活动的商品',
            'product_ids.array'=>'参与活动的产品是多个产品',
            'activity_img.require'=>'请输入活动详情页产品类目图片',
    ];
    protected function imageCollection($value){
        if(empty($value['activity_img_bag']))return '包袋活动图片没有传';
        if(empty($value['activity_img_watch']))return '手表活动图片没有传';
        if(empty($value['activity_img_jewelry']))return '首饰活动图片没有传';
        if(empty($value['activity_ornament']))return '配饰活动图片没有传';
        return true;
    }
}